package com.service.scheduling.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.service.dao.mapper.SysFilConfigMapper;
import com.service.dao.model.SysFilConfig;
import com.service.scheduling.service.SysFilConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SysFilConfigServiceImpl extends ServiceImpl<SysFilConfigMapper, SysFilConfig>
		implements SysFilConfigService {

	@Autowired
	private SysFilConfigMapper sysFilConfigMapper;

	/**
	 * 获取最新有效配置项
	 *
	 * @return
	 */
	@Override
	public SysFilConfig latestConfig() {
		LambdaQueryWrapper<SysFilConfig> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.orderByDesc(SysFilConfig::getCreateTime);
		queryWrapper.eq(SysFilConfig::getStatus,1);
		queryWrapper.last("limit 1");
		SysFilConfig config = sysFilConfigMapper.selectOne(queryWrapper);
		return config;
	}
}
